import { FastifyInstance } from "fastify";
import { ProfessionalCategory, ProfessionalRole } from "@db";

export const student = async (fastify: FastifyInstance) => {
    fastify.get("/professionalRoles", async (req, res) => {
        return res.send(
            (
                await ProfessionalCategory.findAll({
                    include: {
                        model: ProfessionalRole,
                        attributes: ["id", "name"],
                    },
                    attributes: ["id", "name"],
                })
            ).map((x) => {
                return { name: x.name, roles: x.ProfessionalRoles };
            })
        );
    });
};
